package nl.saxion.security.init;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import nl.saxion.security.config.Config;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.name.Named;
/**
 * 
 * @author Martijn
 *	Main class wich will run the frame
 */
public class Main {
	
	@SuppressWarnings("unused")
	private Config config;
	
	private JFrame frame;
	/**
	 * 
	 * @param frame
	 * @param config
	 */
	@Inject
	public Main(JFrame frame, @Named("DefaultConfig") Config config)
	{
		this.frame = frame;
		this.config = config;
	}
	
	/**
	 * Set the frame to visible
	 */
	public void start()
	{
		frame.setVisible(true);
	}
	
	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args)
	{
		Injector injector = Guice.createInjector(new MainModule());
		Main main = injector.getInstance(Main.class);
		
		main.start();
	}
	/**
	 * Closes the project with a errormessage
	 * @param message The errormessage
	 */
	public static void close(String message)
	{
		JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
		Runtime.getRuntime().exit(1); // abnormal end
	}
	
	
	
}
